package lib.bone.flow.domain.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

/**
 * @author: kindear
 * 流程实例表 -- 流程定义实例化
 */

@Data
@Entity
@Table(name = "flow_work")
@GenericGenerator(name = "jpa-uuid", strategy = "uuid")
@EntityListeners(AuditingEntityListener.class)
public class FlowWork {
    @Id
    @GeneratedValue(generator = "jpa-uuid")
    @ApiModelProperty(value = "流程实例ID",name = "id")
    String id;


    @Column(name = "cycle_id")
    @ApiModelProperty(value = "周期ID",notes = "")
    String cycleId;

    @Column(name = "cycle_name")
    @ApiModelProperty(value = "周期名称",notes = "例如:2021-2022 第一学期")
    String cycleName;

    /**
     * 可以使用 JPA 级联映射
     */
    @ApiModelProperty("流程名称")
    @Column(name = "flow_name")
    String flowName;

    @ApiModelProperty("流程定义编码")
    @Column(name = "flow_define_code")
    String flowDefineCode;

    @ApiModelProperty(value = "流程定义",notes = "JSON字符串")
    @Column(name = "flow_define",columnDefinition = "TEXT")
    String flowDefine;

    @ApiModelProperty("最后操作者ID")
    @Column(name = "last_operator")
    String lastOperator;

    @ApiModelProperty("流程发起者ID")
    @Column(name = "initiator")
    String initiator;

    @ApiModelProperty("当前节点ID")
    @Column(name = "current_node_id")
    String currentNodeId;

    @ApiModelProperty("下一节点ID")
    @Column(name = "next_node_id")
    String nextNodeId;
    /**
     * 流程参数， 全流程可访问
     */
    @ApiModelProperty(value = "流程参数",name = "")
    @Column(name = "flow_param",length = 5112)
    String flowParam;

    /**
     * 流程实例是否可以被操作
     */
    @ApiModelProperty(value = "流程锁定态")
    @Column(name = "locked")
    Integer locked;

    @ApiModelProperty(value = "流程实例状态",name = "")
    @Column(name = "flow_work_status")
    String flowWorkStatus;


    @ApiModelProperty(value = "实例状态",notes = "1正常 0被挂起")
    @Column(name = "status")
    Integer status;

    /**
     * 业务类型
     */
    @ApiModelProperty("业务类型")
    @Column(name = "service_type")
    String serviceType;

    /**
     * 关联的业务ID
     */
    @ApiModelProperty("业务ID")
    @Column(name = "service_id")
    String serviceId;


    @ApiModelProperty("业务名称")
    @Column(name = "service_name")
    String serviceName;

    @ApiModelProperty(value = "流程实例到期时间",notes = "")
    @Column(name = "expire_date")
    Date expireDate;

    @CreatedDate
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "记录创建时间",name = "createdTime")
    @Column(name = "created_time")
    private Date createdTime;
    @LastModifiedDate
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "记录更新时间",name = "updatedTime")
    @Column(name = "updated_time")
    private Date updatedTime;
}
